#include "graph.h"

#define DEFAULT_VERTEX(id) {0, 0, id, 0, 0, 0.0, 0.0, NULL, NULL, NULL, 0}
int main(int argc, char** argv)
{
    Graph* graph;
    graph = create_graph();

    int vid = 0;
    int i;

    Vertex vertices[] = {
        DEFAULT_VERTEX(vid++), 
        DEFAULT_VERTEX(vid++), 
        DEFAULT_VERTEX(vid++), 
        DEFAULT_VERTEX(vid++), 
        DEFAULT_VERTEX(vid++), 
        DEFAULT_VERTEX(vid++), 
        //DEFAULT_VERTEX(vid++), 
        //DEFAULT_VERTEX(vid++), 
    };

    for(i = 0; i < 6; i++)
    {
        insert_vertex(graph, &vertices[i]);
    }

    insert_edge(graph, &vertices[0], &vertices[1], 2.0);
    insert_edge(graph, &vertices[0], &vertices[2], 1.0);
    insert_edge(graph, &vertices[1], &vertices[4], 60.0);
    insert_edge(graph, &vertices[1], &vertices[3], 3.0);
    insert_edge(graph, &vertices[2], &vertices[4], 1.0);
    insert_edge(graph, &vertices[3], &vertices[5], 3000066.0);
    insert_edge(graph, &vertices[4], &vertices[5], 4.0);
    //insert_edge(graph, &vertices[5], &vertices[6], 0.0);
    //insert_edge(graph, &vertices[5], &vertices[6], 1.0);
    //insert_edge(graph, &vertices[6], &vertices[7], 1.0);

    print_graph(graph);

    Path * topo_path = malloc(sizeof(Path));
    topo_path->head = NULL;
    topological_sort(graph, topo_path);

    print_path(topo_path);
    double pathLength = 0.0;

    compute_critical_path(topo_path, &pathLength);

    static char *dotName = "test_graph.dot";
    static char *pdfName = "test_graph.pdf";
    generate_graph(graph, dotName, pdfName);

    free(topo_path);
    free_graph(graph);

    return EXIT_SUCCESS;
}
